#include "gtest/gtest.h"
// #include <mockcpp/mokc.h>
// #include <mockcpp/mockcpp.hpp>

#include <vector>
#include <tuple>
#include <iostream>

#include "topoinfo_struct.h"
#include "log.h"
#include "checker_def.h"
#include "topo_meta.h"
#include "testcase_utils.h"
#include "coll_native_executor_base.h"

#include "checker.h"
using namespace checker;

class AllReduceMeshOpbasePipelineExecutorSingleTests : public testing::Test {

public:
    static void SetUpTestCase()
    {
        std::cout << "AllReduceMeshOpbasePipelineExecutor_single set up." << std::endl;
    }

    static void TearDownTestCase()
    {
        std::cout << "AllReduceMeshOpbasePipelineExecutor_single tear down." << std::endl;
    }

    virtual void SetUp()
    {
        const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info();
        std::string caseName = "analysis_result_" + std::string(test_info->test_case_name()) + "_" + std::string(test_info->name());
        Checker::SetDumpFileName(caseName);
    }

    virtual void TearDown()
    {
        Checker::SetDumpFileName("analysis_result");
        // GlobalMockObject::verify();
        // 这边每个case执行完成需要清理所有的环境变量，如果有新增的环境变量，需要在这个函数中进行清理
        ClearHcclEnv();
    }
};

std::vector<CheckerReduceOp> reduceopList = {
    {CheckerReduceOp::REDUCE_SUM},
    {CheckerReduceOp::REDUCE_PROD},
    {CheckerReduceOp::REDUCE_MAX},
    {CheckerReduceOp::REDUCE_MIN}
};

TEST_F(AllReduceMeshOpbasePipelineExecutorSingleTests, all_reduce_algo_server_test)
{

    RankTable_For_LLT gen;
    TopoMeta topoMeta;
    gen.GenTopoMeta(topoMeta, 1, 1, 8);

    CheckerOpParam checkerOpParam;
    checkerOpParam.opType = CheckerOpType::ALLREDUCE;
    checkerOpParam.tag = "AllReduce";
    checkerOpParam.opMode = CheckerOpMode::OPBASE;
    checkerOpParam.devtype = CheckerDevType::DEV_TYPE_910B;
    checkerOpParam.DataDes.count = 100;
    checkerOpParam.DataDes.dataType = CheckerDataType::DATA_TYPE_INT32;
    checkerOpParam.algName = "AllReduceMeshOpbasePipelineExecutor";
    HcclResult ret;
    for (auto &reduceop : reduceopList){
        Checker checker;
        checkerOpParam.reduceType = reduceop;
        checker.CloseRankMemCheck();
        ret = checker.Check(checkerOpParam, topoMeta);
        EXPECT_EQ(ret, HcclResult::HCCL_SUCCESS);
    }
}

